srcdir=         @srcdir@
top_srcdir=     @top_srcdir@
top_builddir=   @top_builddir@
VPATH=          @srcdir@

include ${top_builddir}/Mk/autoconf.mk
include ${top_builddir}/Mk/compile.mk
include ${top_builddir}/Mk/subdir.mk

TEST_OBJS=	tests.o \
		PXTestAssert.o \
		PXTestCase.o \
		PXTestCaseRunner.o \
		PXTestConsoleResultHandler.o \
		PXTestException.o \
		TRArrayTests.o \
		TRAuthLDAPConfigTests.o \
		TRAutoreleasePoolTests.o \
		TRConfigLexerTests.o \
		TRConfigTests.o \
		TRConfigTokenTests.o \
		TRHashTests.o \
		TRLDAPAccountRepositoryTests.o \
		TRLDAPConnectionTests.o \
		TRLDAPEntryTests.o \
		TRLDAPGroupConfigTests.o \
		TRLDAPSearchFilterTests.o \
		TRLocalPacketFilterTests.o \
		TRObjectTests.o \
		mockpf.o \
		TRPFAddressTests.o \
		TRStringTests.o \
		TRVPNSessionTests.o

CFLAGS+=	-DTEST_DATA=\"${srcdir}/data\"
OBJCFLAGS+=	-DTEST_DATA=\"${srcdir}/data\"

LIBS+=		-L${top_builddir}/src -lauth-ldap \
		$(OBJC_LIBS) $(LDAP_LIBS)

LDFLAGS+=	 $(LIBS)

# File Substitutions
EDIT=   sed \
        -e 's,@TEST_DATA\@,$(srcdir)/data,g'

# Recompile the tests every time
all:: tests

# Generate any headers before subdirs are traversed
pre-all:: 

# Generated File(s)
tests.h: tests.h.in
	$(EDIT) $(srcdir)/tests.h.in > $@

tests: ${TEST_OBJS} ../src/libauth-ldap.a
	${CC} -o $@ ${TEST_OBJS} ${LDFLAGS}

test:: tests
	./tests

install::

clean::
	rm -f $(TEST_OBJS) tests

distclean:: clean
	rm -f Makefile
